<?php 


	@include_once("fta.php");
	if (function_exists('fta_registerModules')){
		fta_registerModules(
			array(
			"cmsConfig",
			"site/fta/config",	
			"FTACart/FTACart"
			)
		);
	} else {
		//we could attempt to fangle the include path.. 
	}

	
	class FTAOrderContainer extends CmsOrderContainer {
		
		var $countryList;
		
		function __construct(){
			parent::__construct();
		
			$this->keys = array_merge_recursive(

				array(
					EXTRACT_BOOLEAN => array ("termsAgree")
				),
				array(
					EXTRACT_STRING => array("hearAboutUs")
				),
				$this->keys
			);
			
			$this->dataModelKeyMapping = 
				array_merge(
					$this->dataModelKeyMapping,
					array(	
						"hearAboutUs"=>"extra10",
					)
			);
				
			$this->requiredKeys = array_merge(
				array("termsAgree"),
				$this->requiredKeys
			);
			
		}

		
		function getCountryList(){
			if (is_null($this->countryList)){
				global $db;
				//$countryTableWriter = new CmsTableWriter('country',$db);
				$q = "SELECT * FROM country WHERE iso_3166_1_alpha_2 <> '' AND iso_3166_1_alpha_2 <> 'ZZ' ORDER BY name ASC "; 
				$f = array();
				$cl = $db->getAllAsObjects($q,$f);
				$this->countryList = array();
				foreach ($cl as $c){
					$this->countryList[ $c->id ] = $c;	
				}

			}
			return $this->countryList;		
		}
		
		function countryAsISOCode() {
			$c = $this->valueForKey('countryList');
			return $c[ $this->valueForKey('country')]->name;
		}
	}